/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved.
 *
 */

import { AbilityTypeEnum } from '../../enum/ability-type-enum.js';
import { CodeType } from '../../enum/code-type-enum.js';
import { ConfigJson } from '../../options/configure/config-json-options.js';

import { LegacyAbilityModel } from './legacy-ability-model.js';
import ConfigOptObj = ConfigJson.ConfigOptObj;
import { resModelLoader } from '../../utils/loader/file/res-model-loader.js';

/**
 * Fa模型中的form数据模型
 *
 * @since 2022/3/08
 */
export class LegacyFormModelImpl implements LegacyAbilityModel {
  private readonly _configObj: ConfigOptObj;
  private readonly _jsName: string;
  private readonly _jsObj: ConfigJson.JsObj | undefined;

  constructor(configJson: string, jsObj: ConfigJson.JsObj) {
    this._configObj = resModelLoader.getConfigJson(configJson);
    this._jsObj = jsObj;
    this._jsName = jsObj.name;
  }

  getRelateSrcPath(): string {
    return this.getName();
  }

  getName(): string {
    return this._jsName;
  }

  getSrcLanguage(): CodeType {
    return CodeType.JS;
  }

  getType(): AbilityTypeEnum {
    // require page
    return AbilityTypeEnum.PAGE;
  }

  getConfigJsonJsObj(): ConfigJson.JsObj | undefined {
    return this._jsObj;
  }
}
